package com.coolpad.Utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

public class DateTimeUtils {
    public static final int TIME_DAY_MILLISECOND = 86400000;
    public static final int TIME_15MINUTES_SECOND = 900;
    public static final int TIME_HOUR_MILLISECOND = 3600000;
    public static final int TIME_15MINUTES_MILLISECOND = 900000;
    private static final String DATE_FORMAT = "yyyy-MM-dd";
    private static final String DATE_FORMAT_CN = "yyyy年MM月dd日";
    private static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
    private static final String TIME_FORMAT_00 = "yyyy-MM-dd HH:00:00";
    private static final String TIME_FORMAT_59 = "yyyy-MM-dd HH:59:59";
    private static final String TIME_FORMAT_15 = "yyyy-MM-dd HH:mm:00";
    private static final String DATE_FORMAT_00 = "yyyy-MM-dd 00:00:00";
    private static final String DATE_FORMAT_2359 = "yyyy-MM-dd 23:59:59";
    private static final String TIME_FORMAT_CN = "yyyy年MM月dd日 HH:mm:ss";
    private static final String MONTH_FORMAT = "yyyy-MM";
    private static final String DAY_FORMAT = "yyyyMMdd";
    private static final String TIME_FORMAT_NUM = "MMddHHmmss";

    public DateTimeUtils() {
    }

    public static String GetUTCTimeStamp() {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        f.setTimeZone(TimeZone.getTimeZone("UTC"));
        return f.format(new Date());
    }

    public static Date getCurrDate() {
        return new Date();
    }

    public static Timestamp getCurrTimestamp() {
        return new Timestamp(System.currentTimeMillis());
    }

    public static Integer getCurrDateAMorPM() {
        Calendar calendar = Calendar.getInstance();
        return calendar.get(9);
    }

    public static String getFormatDate(Date currDate) {
        return getFormatDate(currDate, "yyyy-MM-dd");
    }

    public static String getCurDateStr2() {
        Date dt = getCurrDate();
        return getCurDateStr2Helper(dt);
    }

    public static String getCurDateStr2Helper(Date dt) {
        String FORMAT = "yyyy-M-d";
        return getFormatDate(dt, FORMAT);
    }

    public static Date getFormatDateToDate(Date currDate) {
        return getFormatDate(getFormatDate(currDate));
    }

    public static String getFormatDate_CN(Date currDate) {
        return getFormatDate(currDate, "yyyy年MM月dd日");
    }

    public static Date getFormatDateToDate_CN(Date currDate) {
        return getFormatDate_CN(getFormatDate_CN(currDate));
    }

    public static Date getFormatDate(String currDate) {
        return getFormatDate(currDate, "yyyy-MM-dd");
    }

    public static Date getFormatDate_CN(String currDate) {
        return getFormatDate(currDate, "yyyy年MM月dd日");
    }

    public static String getFormatDate(Date currDate, String format) {
        SimpleDateFormat dtFormatdB = null;

        try {
            dtFormatdB = new SimpleDateFormat(format);
            return dtFormatdB.format(currDate);
        } catch (Exception var6) {
            dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");

            try {
                return dtFormatdB.format(currDate);
            } catch (Exception var5) {
                return null;
            }
        }
    }

    public static int getYear(Date date) {
        String year = getFormatDate(date, "yyyy");
        return Integer.parseInt(year);
    }

    public static int getMonth(Date date) {
        String year = getFormatDate(date, "MM");
        return Integer.parseInt(year);
    }

    public static int getDay(Date date) {
        String year = getFormatDate(date, "dd");
        return Integer.parseInt(year);
    }

    public static String getFormatDateTime(Date currDate) {
        return getFormatDateTime(currDate, "yyyy-MM-dd HH:mm:ss");
    }

    public static Date getFormatDateTimeToTime(Date currDate) {
        return getFormatDateTime(getFormatDateTime(currDate));
    }

    public static Date getFormatDateTime(String currDate) {
        return getFormatDateTime(currDate, "yyyy-MM-dd HH:mm:ss");
    }

    public static String getFormatDateTime_CN(Date currDate) {
        return getFormatDateTime(currDate, "yyyy年MM月dd日 HH:mm:ss");
    }

    public static Date getFormatDateTimeToTime_CN(Date currDate) {
        return getFormatDateTime_CN(getFormatDateTime_CN(currDate));
    }

    public static Date getFormatDateTime_CN(String currDate) {
        return getFormatDateTime(currDate, "yyyy年MM月dd日 HH:mm:ss");
    }

    public static String getFormatDateTime(Date currDate, String format) {
        SimpleDateFormat dtFormatdB = null;

        try {
            dtFormatdB = new SimpleDateFormat(format);
            return dtFormatdB.format(currDate);
        } catch (Exception var6) {
            dtFormatdB = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            try {
                return dtFormatdB.format(currDate);
            } catch (Exception var5) {
                return null;
            }
        }
    }

    public static Date getFormatDate(String currDate, String format) {
        SimpleDateFormat dtFormatdB = null;

        try {
            dtFormatdB = new SimpleDateFormat(format);
            return dtFormatdB.parse(currDate);
        } catch (Exception var6) {
            dtFormatdB = new SimpleDateFormat("yyyy-MM-dd");

            try {
                return dtFormatdB.parse(currDate);
            } catch (Exception var5) {
                return null;
            }
        }
    }

    public static long getISOFormatDateMilliSecond(String timeString) {
        DateTimeFormatter DATE_TIME_PARSER = ISODateTimeFormat.dateTimeParser();
        return DATE_TIME_PARSER.parseDateTime(timeString).getMillis();
    }

    public static Date getFormatDateTime(String currDate, String format) {
        SimpleDateFormat dtFormatdB = null;

        try {
            dtFormatdB = new SimpleDateFormat(format);
            return dtFormatdB.parse(currDate);
        } catch (Exception var6) {
            dtFormatdB = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            try {
                return dtFormatdB.parse(currDate);
            } catch (Exception var5) {
                return null;
            }
        }
    }

    public static String getDateBeforeMonth() {
        Calendar cal = Calendar.getInstance();
        cal.add(2, -1);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static String getDateBeforeMonth(int number) {
        Calendar cal = Calendar.getInstance();
        cal.add(2, -number);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static long getDaysOfDates(Date first, Date second) {
        Date d1 = getFormatDateTime(getFormatDate(first), "yyyy-MM-dd");
        Date d2 = getFormatDateTime(getFormatDate(second), "yyyy-MM-dd");
        long mils = d1.getTime() - d2.getTime();
        return mils / 86400000L;
    }

    public static int getDaysBetweenDates(Date first, Date second) {
        Date d1 = getFormatDateTime(getFormatDate(first), "yyyy-MM-dd");
        Date d2 = getFormatDateTime(getFormatDate(second), "yyyy-MM-dd");
        Long mils = (d2.getTime() - d1.getTime()) / 86400000L;
        return mils.intValue();
    }

    public static int getDaysBetweenDates(String first, String second) {
        Date d1 = getFormatDateTime(first, "yyyy-MM-dd");
        Date d2 = getFormatDateTime(second, "yyyy-MM-dd");
        Long mils = (d2.getTime() - d1.getTime()) / 86400000L;
        return mils.intValue();
    }

    public static List<Date> getDaysListBetweenDates(Date first, Date second) {
        List<Date> dateList = new ArrayList();
        Date d1 = getFormatDateTime(getFormatDate(first), "yyyy-MM-dd");
        Date d2 = getFormatDateTime(getFormatDate(second), "yyyy-MM-dd");
        if (d1.compareTo(d2) > 0) {
            return dateList;
        } else {
            do {
                dateList.add(d1);
                d1 = getDateBeforeOrAfter(d1, 1);
            } while(d1.compareTo(d2) <= 0);

            return dateList;
        }
    }

    public static String getDateBeforeDay() {
        Calendar cal = Calendar.getInstance();
        cal.add(6, -1);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static String getCurrDateStr() {
        return getFormatDate(getCurrDate());
    }

    public static String getCurrDateTimeStr() {
        return getFormatDateTime(getCurrDate());
    }

    public static String getCurrDateStr_CN() {
        return getFormatDate(getCurrDate(), "yyyy年MM月dd日");
    }

    public static String getCurrDateTimeStr_CN() {
        return getFormatDateTime(getCurrDate(), "yyyy年MM月dd日 HH:mm:ss");
    }

    public static Date getDateBeforeOrAfter(int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.add(5, iDate);
        return cal.getTime();
    }

    public static Date getDateBeforeOrAfter(Date curDate, int iDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(5, iDate);
        return cal.getTime();
    }

    public static String getFormatMonth(Date currDate) {
        return getFormatDate(currDate, "yyyy-MM");
    }

    public static String getFormatDay(Date currDate) {
        return getFormatDate(currDate, "yyyyMMdd");
    }

    public static String getFormatTime(Date currDate) {
        return getFormatDate(currDate, "MMddHHmmss");
    }

    public static String getFirstDayOfMonth() {
        Calendar cal = Calendar.getInstance();
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static String getFirstDayOfNextMonth() {
        Calendar cal = Calendar.getInstance();
        cal.add(2, 1);
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static Date getFirstDayOfLastMonth() {
        Calendar cal = Calendar.getInstance();
        cal.add(2, -1);
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00"));
    }

    public static Date getLastDayOfLastMonth() {
        Date date = getFirstDayOfLastMonth();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int lastDay = cal.getActualMaximum(5);
        cal.set(5, lastDay);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 23:59:59"));
    }

    public static Date getThisDayOfLastMonth(Date curDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(2, -1);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00"));
    }

    public static Date getFirstDayOfThisMonth() {
        Calendar cal = Calendar.getInstance();
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00"));
    }

    public static String getFirstDayOfMonth(Date currDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(currDate);
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static String getLastDayOfMonth(Date currDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(currDate);
        int lastDay = cal.getActualMaximum(5);
        cal.set(5, lastDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static String getLastDayOfMonth() {
        Calendar cal = Calendar.getInstance();
        int lastDay = cal.getActualMaximum(5);
        cal.set(5, lastDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static Date getDateBeforeOrAfterHours(Date curDate, int iHour) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(11, iHour);
        return cal.getTime();
    }

    public static Date getDateBeforeOrAfterMins(Date curDate, int iMins) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(12, iMins);
        return cal.getTime();
    }

    public static Date getDateLastHour(Date curDate) {
        return getFormatDateTime(getFormatDate(getDateBeforeOrAfterHours(curDate, -1), "yyyy-MM-dd HH:00:00"));
    }

    public static Date getDateLastHourEnd(Date curDate) {
        return getFormatDateTime(getFormatDate(getDateBeforeOrAfterHours(curDate, -1), "yyyy-MM-dd HH:59:59"));
    }

    public static Date getDateThisHour(Date curDate) {
        return getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd HH:00:00"));
    }

    public static Date getDateThis15Min(Date curDate) {
        return getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd HH:mm:00"));
    }

    public static Date getDateLastDay(Date curDate) {
        return getFormatDateTime(getFormatDate(getDateBeforeOrAfter(curDate, -1), "yyyy-MM-dd 00:00:00"));
    }

    public static Date getDateStart(Date curDate) {
        return getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
    }

    public static Date getDateEnd(Date curDate) {
        return getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 23:59:59"));
    }

    public static Date getDateLastDayEnd(Date curDate) {
        return getFormatDateTime(getFormatDate(getDateBeforeOrAfter(curDate, -1), "yyyy-MM-dd 23:59:59"));
    }

    public static Date getDateThisDay(Date curDate) {
        return getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
    }

    public static Date getDateLastWeek(Date curDate) {
        curDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(3, -1);
        int firstDay = cal.getMinimum(7);
        cal.set(7, firstDay);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00"));
    }

    public static Date getDateThisWeek(Date curDate) {
        curDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        cal.add(3, -1);
        int lastDay = cal.getMaximum(7);
        cal.set(7, lastDay);
        return getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 23:59:59"));
    }

    public static List<Date> getDaysOfWeek(Date curDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        int firstDay = cal.getMinimum(7);
        cal.set(7, firstDay);
        List<Date> lst = new ArrayList();
        lst.add(getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00")));
        cal.clear();
        cal.setTime(curDate);
        int lastDay = cal.getMaximum(7);
        cal.set(7, lastDay);
        lst.add(getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 23:59:59")));
        return lst;
    }

    public static List<Date> getDaysOfMon(Date curDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(curDate);
        int firstDay = cal.getMinimum(5);
        cal.set(5, firstDay);
        List<Date> lst = new ArrayList();
        lst.add(getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 00:00:00")));
        cal.roll(5, -1);
        lst.add(getFormatDateTime(getFormatDate(cal.getTime(), "yyyy-MM-dd 23:59:59")));
        return lst;
    }

    public static List<Date> getDaysOf7Days(Date curDate) {
        Date sCurDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
        Date iCurDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 23:59:59"));
        List<Date> lst = new ArrayList();
        lst.add(getDateBeforeOrAfter(sCurDate, -6));
        lst.add(iCurDate);
        return lst;
    }

    public static List<Date> getDaysOf30Days(Date curDate) {
        Date sCurDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 00:00:00"));
        Date iCurDate = getFormatDateTime(getFormatDate(curDate, "yyyy-MM-dd 23:59:59"));
        List<Date> lst = new ArrayList();
        lst.add(getDateBeforeOrAfter(sCurDate, -29));
        lst.add(iCurDate);
        return lst;
    }

    public static boolean isSameWeek(Date curDate, Date compareDate) {
        if (curDate != null && compareDate != null) {
            Calendar calSun = Calendar.getInstance();
            calSun.setTime(getFormatDateToDate(curDate));
            calSun.set(7, 1);
            Calendar calNext = Calendar.getInstance();
            calNext.setTime(calSun.getTime());
            calNext.add(5, 7);
            Calendar calComp = Calendar.getInstance();
            calComp.setTime(compareDate);
            return calComp.after(calSun) && calComp.before(calNext);
        } else {
            return false;
        }
    }

    public static String addDateEndfix(String datestring) {
        return datestring != null && !datestring.equals("") ? datestring + " 23:59:59" : null;
    }

    public static Date getFormatDateEndfix(String dateStr) {
        dateStr = addDateEndfix(dateStr);
        return getFormatDateTime(dateStr);
    }

    public static Date formatEndTime(String datePre) {
        if (datePre == null) {
            return null;
        } else {
            String dateStr = addDateEndfix(datePre);
            return getFormatDateTime(dateStr);
        }
    }

    public static Boolean compareDay(Date date1, int compday) {
        if (date1 == null) {
            return false;
        } else {
            Date dateComp = getDateBeforeOrAfter(date1, compday);
            Date nowdate = new Date();
            return dateComp.after(nowdate) ? true : false;
        }
    }

    public static String convertBinaryTime2Hex(String timespan) {
        if (timespan != null && !timespan.equals("")) {
            String ret = "";
            String tmp = "";

            for(int i = 0; i < timespan.length(); ++i) {
                tmp = tmp + timespan.charAt(i);
                tmp = tmp + timespan.charAt(i);
                if ((i + 1) % 16 == 0) {
                    if (!ret.equals("")) {
                        ret = ret + ",";
                    }

                    Long t = Long.parseLong(tmp, 2);
                    String hexStr = Long.toHexString(t);
                    if (hexStr.length() < 8) {
                        int length = hexStr.length();

                        for(int n = 0; n < 8 - length; ++n) {
                            hexStr = "0" + hexStr;
                        }
                    }

                    ret = ret + hexStr;
                    tmp = "";
                }
            }

            return ret;
        } else {
            return "";
        }
    }

    public static String convertHexTime2Binary(String timespan) {
        if (timespan != null && !timespan.equals("")) {
            String tmp = "";
            String ret = "";
            String[] strArr = timespan.split(",");

            int i;
            for(i = 0; i < strArr.length; ++i) {
                String binStr = Long.toBinaryString(Long.parseLong(strArr[i], 16));
                if (binStr.length() < 32) {
                    int length = binStr.length();

                    for(int n = 0; n < 32 - length; ++n) {
                        binStr = "0" + binStr;
                    }
                }

                tmp = tmp + binStr;
            }

            for(i = 0; i < 48; ++i) {
                ret = ret + tmp.charAt(i * 2);
            }

            return ret;
        } else {
            return "";
        }
    }

    public static String convertDecTime2Binary(String timespan) {
        if (timespan != null && !timespan.equals("")) {
            String tmp = "";
            String ret = "";
            String[] strArr = timespan.split(",");

            int i;
            for(i = 0; i < strArr.length; ++i) {
                String binStr = Long.toBinaryString(Long.parseLong(strArr[i], 10));
                if (binStr.length() < 32) {
                    int length = binStr.length();

                    for(int n = 0; n < 32 - length; ++n) {
                        binStr = "0" + binStr;
                    }
                }

                tmp = tmp + binStr;
            }

            for(i = 0; i < 48; ++i) {
                ret = ret + tmp.charAt(i * 2);
            }

            return ret;
        } else {
            return "";
        }
    }

    public static String convertBinaryTime2Dec(String timespan) {
        if (timespan != null && !timespan.equals("")) {
            String ret = "";
            String tmp = "";

            for(int i = 0; i < timespan.length(); ++i) {
                tmp = tmp + timespan.charAt(i);
                tmp = tmp + timespan.charAt(i);
                if ((i + 1) % 16 == 0) {
                    if (!ret.equals("")) {
                        ret = ret + ",";
                    }

                    Long t = Long.parseLong(tmp, 2);
                    String decStr = Long.toString(t);
                    if (decStr.length() < 10) {
                        int length = decStr.length();

                        for(int n = 0; n < 10 - length; ++n) {
                            decStr = "0" + decStr;
                        }
                    }

                    ret = ret + decStr;
                    tmp = "";
                }
            }

            return ret;
        } else {
            return "";
        }
    }

    public static String genericSpecdate(Date date, int addMonth, int monthDay) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(2, addMonth);
        cal.set(5, monthDay);
        return getFormatDate(cal.getTime(), "yyyy-MM-dd");
    }

    public static Date getDateBeforeOrAfterV2(int idx) {
        return getDateBeforeOrAfter(getFormatDateToDate(getCurrDate()), idx);
    }

    public static Date getSpecifiedDateTimeBySeconds(Date curDate, int seconds) {
        long time = curDate.getTime() / 1000L + (long)seconds;
        curDate.setTime(time * 1000L);
        return curDate;
    }

    public static boolean isBeforeOrAfter15Minutes(Date date) {
        Date beforeDate = getSpecifiedDateTimeBySeconds(getCurrDate(), -900);
        Date afterDate = getSpecifiedDateTimeBySeconds(getCurrDate(), 900);
        return date.before(afterDate) && date.after(beforeDate);
    }

    public static boolean isBefore15Minutes(Date date) {
        Date beforeDate = getSpecifiedDateTimeBySeconds(getCurrDate(), -900);
        Date afterDate = getSpecifiedDateTimeBySeconds(getCurrDate(), 0);
        return date.before(afterDate) && date.after(beforeDate);
    }

    public static Date getSpecifiedDateTime_235959(Date curDate) {
        return getSpecifiedDateTimeBySeconds(getFormatDateToDate(curDate), 86399);
    }

    public static String getSpecifiedDateTime_month(Date curDate) {
        return getFormatDateTime(curDate, "MM.dd");
    }

    public static String getLocalTime(long timeStamp, String format, int beforeDays) {
        if (format == null) {
            format = "yyyy-MM-dd";
        }

        Calendar cal = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        cal.setTimeInMillis(timeStamp);
        cal.add(5, beforeDays);
        return formatter.format(cal.getTime());
    }

    public static String getFormatTime(long timeStamp, String format) {
        if (format == null) {
            format = "yyyy-MM-dd";
        }

        Calendar cal = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        cal.setTimeInMillis(timeStamp);
        return formatter.format(cal.getTime());
    }

    public static Date getCurrentDate(int hour, int minute, int second) {
        Calendar cal = Calendar.getInstance();
        cal.set(11, hour);
        cal.set(12, minute);
        cal.set(13, second);
        return cal.getTime();
    }

    public static Date getNeedTime(Date curDate, String dtime, int d) {
        if (dtime.equalsIgnoreCase("d")) {
            return getDateBeforeOrAfter(curDate, d);
        } else {
            return dtime.equalsIgnoreCase("h") ? getDateBeforeOrAfterHours(curDate, d) : getDateBeforeOrAfterMins(curDate, d);
        }
    }

    public static List<String> getBeforeOrAfterDateList(Date date, String format, int interval) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        List<String> dateList = new ArrayList();
        dateList.add(getFormatDate(cal.getTime(), format));
        int i = interval;
        if (interval > 0) {
            while(i-- != 0) {
                cal.add(5, 1);
                dateList.add(getFormatDate(cal.getTime(), format));
            }
        } else {
            while(i++ != 0) {
                cal.add(5, -1);
                dateList.add(getFormatDate(cal.getTime(), format));
            }
        }

        return dateList;
    }

    public static int getBeforeOrAfterTimeSeconds(int dayOffset) {
        int rowOneDate = (int)Math.floor((double)(getDateLastDayEnd(getDateBeforeOrAfter(dayOffset)).getTime() / 1000L));
        return rowOneDate;
    }

    public static boolean isToday(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.set(11, 23);
        cal.set(12, 59);
        cal.set(13, 59);
        long diff = cal.getTimeInMillis() - date.getTime();
        if (diff < 0L) {
            return false;
        } else {
            return diff / 86400000L == 0L;
        }
    }

    public static long getMillisecondsOfToday() {
        Calendar cal = Calendar.getInstance();
        return (long)(cal.get(11) * 60 * 60 * 1000 + cal.get(12) * 60 * 1000 + cal.get(13) * 1000);
    }
}
